import React, { Component } from "react";
import { Button } from "antd";

class index extends Component {
  // 向父组件传值
  delete = (id) => {
    this.props.deleteItem(id);
  };
  isCheck = (id) => {
    this.props.checkItem(id);
  };
  render() {
    return (
      <div>
        {this.props.data.map((item) => {
          return (
            <div key={item.id} style = {{display:'flex', justifyContent: "space-between", marginTop:'5px'}}>
              <p>
                <input type="checkbox" checked={item.done} onChange={ this.isCheck.bind(this, item.id) }/>&nbsp;&nbsp;
                {item.content}
              </p>
              <Button
                type="primary"
                danger
                onClick={this.delete.bind(this, item.id)}
              >
                删除
              </Button>
            </div>
          );
        })}
      </div>
    );
  }
}

export default index;
